package com.service.hpt.impl;

import com.dao.*;
import com.entity.*;
import com.service.hpt.RegisterBookService;
import com.util.gzp.AjaxResponse;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


@Service
@Transactional
public class RegisterBookServiceImpl  implements RegisterBookService {

    @Resource
    private RegisterbookDao registerbookDao;//登记簿
    @Resource
    private HouseDao houseDao;//楼盘
    @Resource
    private NetsignDao netsignDao;//网签
    @Resource
    private ServiceDao serviceDao;//业务表
    @Resource
    private ServiceshareDao serviceshareDao;//共有人表
    @Resource
    private  ClientDao clientDao;//客户表
    @Resource
    private  UserinfoDao userinfoDao;//用户表
    @Resource
    private  ProvincesDao provincesDao;//省份
    @Resource
    private  AreasDao areasDao;//区
    @Resource
    private  CitiesDao citiesDao;//市
    @Resource
    private  GainingmethodDao gainingmethodDao;//取得方式表
    @Resource
    private  LandnumberDao landnumberDao;//土地证号表
    @Resource
    private  OwnershipDao ownershipDao;//所有权表
    @Resource
    private  LanduseDao landuseDao;//土地用途表
    @Resource
    private  BuildingstructureDao buildingstructureDao;//房屋结构表
    @Resource
    private  RoomDao roomDao;//房屋表
    @Resource
    private BuildingDao buildingDao;//楼栋
    @Resource
    private  RoomtypeDao roomtypeDao;//房屋性质
    @Resource
    private  ExistmortgageDao existmortgageDao;//他项权（现房抵押）
    @Resource
    private  BeinmortgageDao beinmortgageDao;//他项权（在建抵押）
    @Resource
    private  CloseregistrationDao closeregistrationDao;//查封登记
    @Resource
    private  OtherregistrationDao otherregistrationDao;//其他预告登记
    @Resource
    private  RegistrationtypeDao registrationtypeDao;//预告登记种类
    @Resource
    private  CloseofficeDao closeofficeDao;//查封机关
    @Resource
    private  DissentingregistrationDao dissentingregistrationDao;//异议登记



//查询所有的登记簿
    @Override
    public AjaxResponse getAllRegisterBook() {
       //所有的登记簿


        List<Registerbook> registerbookList = registerbookDao.selectByExample(null);
        List<RegisterBookList> list = new ArrayList<>();//容器
        List<Registerbook> list2 = new ArrayList<>();//容器
        System.out.println("所有的登记簿:"+registerbookList);

        for (int i=0;i<7;i++){
            Registerbook registerbook = registerbookList.get(i);
            list2.add(registerbook);
            System.out.println("list2:"+list2);
        }

        //遍历所有的登记簿
        for(Registerbook rb:list2){
            System.out.println("遍历到的登记簿:"+rb);
            RegisterBookList rbl = new RegisterBookList();
            //1、登记簿编号
            System.out.println("登记簿编号:"+rb.getRegisterbookno());
           rbl.setRegisterbookno(rb.getRegisterbookno());
            //2、房屋坐落(根据楼盘id查到)
            House house = houseDao.selectByPrimaryKey(rb.getHid());
            System.out.println("房屋坐落:"+house.getLocation());
            rbl.setLocation(house.getLocation());
            //3.所有权人
            //根据房屋id查到购房人id组
            NetsignExample example = new NetsignExample();
            NetsignExample.Criteria criteria = example.createCriteria();
            criteria.andRoomidEqualTo(rb.getRoomid());
            List<Netsign> netsignList = netsignDao.selectByExample(example);//网签对象组
            Integer[] buyers=new Integer[netsignList.size()];//购房人id组
            Integer[] serviceids=new Integer[netsignList.size()];//业务id组


            String str="";
            for (int i=0;i<netsignList.size();i++) {
                 buyers[i]=netsignList.get(i).getBuyer();//购房人id组
                System.out.println("购房人id:"+buyers[i]);
                //根据购房人id组查到业务id组
                ServiceExample example1 = new ServiceExample();
                ServiceExample.Criteria criteria1 = example1.createCriteria();
                criteria1.andProposerEqualTo(buyers[i]);
                serviceids[i]=serviceDao.selectByExample(example1).get(0).getServiceid();
                System.out.println("业务id:"+serviceids[i]);

            }
            System.out.println("业务id组:"+Arrays.toString(serviceids));

            for(int i=0;i<serviceids.length;i++){
                System.out.println("业务id："+serviceids[i]);
                //根据业务id组查到共有人表对象组
                ServiceshareExample example2 = new ServiceshareExample();
                ServiceshareExample.Criteria criteria2 = example2.createCriteria();
                criteria2.andServiceidEqualTo( serviceids[i]);

                Serviceshare serviceshare = serviceshareDao.selectByExample(example2).get(0);

                System.out.println("客户id："+serviceshare.getClientid());
                Client client = clientDao.selectByPrimaryKey(serviceshare.getClientid());//客户对象
                String clientname =client!=null?client.getClientname():"";
                System.out.println("共有人："+clientname);
                Integer share = serviceshare.getShare();//份额
                System.out.println("份额:"+share);
                if(serviceshare.getSharetypeid()==3){
                    str+=clientname;
                }else{
                    str+=clientname + "(" + share + ")" + " ";
                }

            }
            System.out.println("共有人表对象组:"+str);

            rbl.setObligeeAndShare(str);
            //4、丘号
            rbl.setQiuhao(rb.getClientid());//自定义值
            System.out.println("丘号:"+rb.getClientid());
            //5、登记时间
            //根据网签对象查到网签时间
            NetsignExample example1 = new NetsignExample();
            NetsignExample.Criteria criteria1 = example1.createCriteria();
            criteria1.andRoomidEqualTo(rb.getRoomid());
            Netsign netsign = netsignDao.selectByExample(example1).get(0);
            System.out.println("登记时间:"+netsign.getNettime());
            rbl.setRegistertime(netsign.getNettime());
            //6、登簿人
            String uname = userinfoDao.selectByPrimaryKey(rb.getUid()).getUname();
            System.out.println("登簿人:"+uname);
            rbl.setUname(uname);
            //7、房屋id
            System.out.println("房屋id"+rb.getRoomid());
            rbl.setRoomid(rb.getRoomid());


            //判断登记簿是否注销
            if (rb.getDelstatus()==1){
                list.add(rbl);
            }else{
                rbl=null;
                list.add(rbl);
            }


        }


        return AjaxResponse.success(list);
    }

    @Override
    //根据登记簿编号查询登记簿
    public AjaxResponse getRegisterBook(int registerbookNo) {
        List<RegisterBookList> list=new ArrayList<>();
        RegisterBookList rbl = new RegisterBookList();

        RegisterbookExample example = new RegisterbookExample();
        RegisterbookExample.Criteria criteria = example.createCriteria();
        criteria.andRegisterbooknoEqualTo(registerbookNo);

        //现房抵押组
        List<Existmortgage> existmortgageArrayList=new ArrayList<>();

        Registerbook rb = registerbookDao.selectByExample(example).get(0);
        System.out.println("登记簿编号："+registerbookNo);



        //1、登记簿编号
          rbl.setRegisterbookno(registerbookNo);

        //2、房屋坐落(根据楼盘id查到)
        House house = houseDao.selectByPrimaryKey(rb.getHid());
        System.out.println("房屋坐落:"+house.getLocation());
        rbl.setLocation(house.getLocation());


        //区
        Areas areas = areasDao.selectByPrimaryKey(house.getZid());
        String area = areas.getArea();//区名称
        System.out.println("区1111111111111："+area);
        int cityId = Integer.parseInt(areas.getCityid());//市id
        rbl.setAreas(area);
        //市
        Cities cities = citiesDao.selectByPrimaryKey(cityId);
        String city = cities.getCity();//市名称
        Integer provinceid= Integer.parseInt(cities.getProvinceid());//省id
        rbl.setCities(city);
        //省
        Provinces provinces = provincesDao.selectByPrimaryKey(provinceid);
        String province = provinces.getProvince();//省名称
        System.out.println("省333333333333333："+province);
        rbl.setProvinces(province);

        //土地取得方式
        String gname = gainingmethodDao.selectByPrimaryKey(house.getGid()).getGname();
        rbl.setGname(gname);
        //土地证号
        String lnname = landnumberDao.selectByPrimaryKey(house.getLnid()).getLnname();
         rbl.setLnname(lnname);

        //业务宗号
        Ownership ownership = ownershipDao.selectByPrimaryKey(rb.getOsid());
        String servicenumber = ownership.getServicenumber();
        rbl.setServicenumber(servicenumber);
        //规划用途
        String lname = landuseDao.selectByPrimaryKey(house.getLid()).getLname();
        rbl.setLname(lname);
        //房屋结构
        String bsname = buildingstructureDao.selectByPrimaryKey(house.getBsid()).getBsname();
        rbl.setBsname(bsname);
        //建筑名称
        Integer buildingid = roomDao.selectByPrimaryKey(rb.getRoomid()).getBuildingid();
        Building building = buildingDao.selectByPrimaryKey(buildingid);//建筑物
        String buildingname = building.getBuildingname();//建筑名称
        rbl.setBuildingname(buildingname);
        String buildingnumber = building.getBuildingnumber();//建筑编号
         rbl.setBuildingnumber(buildingnumber);


        //3.所有权人
        //根据房屋id查到购房人id组
        NetsignExample example1 = new NetsignExample();
        NetsignExample.Criteria criteria3 = example1.createCriteria();
        criteria3.andRoomidEqualTo(rb.getRoomid());
        List<Netsign> netsignList = netsignDao.selectByExample(example1);//网签对象组
        Integer[] buyers=new Integer[netsignList.size()];//购房人id组
        Integer[] serviceids=new Integer[netsignList.size()];//业务id组
        Integer[] roomids=new Integer[netsignList.size()];//房屋id组
        String [] clientnames=new String[netsignList.size()];//所有权人组
        String [] idcards=new String[netsignList.size()];//身份证组
        String [] addresses=new String[netsignList.size()];//户籍地址组
        String [] commones=new String[netsignList.size()];//共有情况组
        String [] gnames=new String[netsignList.size()];//取得方式组
        String [] rnames=new String[netsignList.size()];//房屋性质组
        Integer [] osids=new Integer[netsignList.size()];//所有权证号组
        Date [] registertimes=new Date[netsignList.size()];//登记时间组
        String [] unames=new String[netsignList.size()];//用户名称组





        String str="";
        for (int i=0;i<netsignList.size();i++) {
            buyers[i]=netsignList.get(i).getBuyer();//购房人id组
            //根据购房人id组查到业务id组
            ServiceExample example2 = new ServiceExample();
            ServiceExample.Criteria criteria4 = example2.createCriteria();
            criteria4.andProposerEqualTo(buyers[i]);
            serviceids[i]=serviceDao.selectByExample(example2).get(0).getServiceid();
            System.out.println("业务id:"+serviceids[i]);

            //根据网签对象查到房屋id组
            roomids[i] = netsignList.get(i).getRoomid();
            OwnershipExample example3 = new OwnershipExample();
            OwnershipExample.Criteria criteria1 = example3.createCriteria();
            criteria1.andRoomidEqualTo(roomids[i]);
            Date registertime = ownershipDao.selectByExample(example3).get(0).getRegistertime();
            registertimes[i]=registertime;
            gnames[i]=gname;

        }

        //异议登记
        Integer [] deserviceid=new Integer[serviceids.length];
        Integer svid[]=new Integer[serviceids.length];//业务宗号
        String clientname6[]=new String[serviceids.length];//申请人
        String distingitem[]=new String[serviceids.length];
        Date rtime[]=new Date[serviceids.length];  //登记时间
        String uname33[]=new String[serviceids.length];//登簿人
        Integer disid[]=new Integer[serviceids.length];//异议注销业务宗号

        //根据房屋id查到异议登记表
        DissentingregistrationExample example8 = new DissentingregistrationExample();
        DissentingregistrationExample.Criteria criteria8 = example8.createCriteria();
        criteria8.andDescriptEqualTo(String.valueOf(rb.getRoomid()));
        List<Dissentingregistration> dissentingregistrationList = dissentingregistrationDao.selectByExample(example8);
        for(int i=0;i<dissentingregistrationList.size();i++){
            svid[i]=dissentingregistrationList.get(0).getServiceid();//业务宗号
            clientname6[i]=clientDao.selectByPrimaryKey(dissentingregistrationList.get(0).getClientid()).getClientname();//申请人
            distingitem[i]=dissentingregistrationList.get(0).getDissentingitem();//异议事项
            rtime[i]=dissentingregistrationList.get(0).getRegistertime();  //登记时间
            uname33[i]=userinfoDao.selectByPrimaryKey(dissentingregistrationList.get(0).getUid()).getUname();//登簿人
            disid[i]=dissentingregistrationList.get(0).getDissentingserviceid();//异议注销业务宗号


        }
        rbl.setDisid(disid);
        rbl.setUname33(uname33);
        rbl.setRtime(rtime);
        rbl.setDistingitem(distingitem);
        rbl.setClientname6(clientname6);
        rbl.setSvid(svid);






       //预告登记
        OtherregistrationExample example3 = new OtherregistrationExample();
        OtherregistrationExample.Criteria criteria6 = example3.createCriteria();
        criteria6.andRoomidEqualTo(rb.getRoomid());
        List<Otherregistration> otherregistrations = otherregistrationDao.selectByExample(example3);
        Integer sid1[]=new Integer[otherregistrations.size()];//业务宗号
        String  type1[]=new String[otherregistrations.size()];//预告登记种类
        String obl[]=new String[otherregistrations.size()];
        String no1[]=new String[otherregistrations.size()];//权利人身份证号
        String obl2[]=new String[otherregistrations.size()];//义务人
        String no2[]=new String[otherregistrations.size()];//义务人身份证
        String preno []=new String[otherregistrations.size()];//预告登记证明号
        Date time1[]=new Date[otherregistrations.size()];//登记时间
        String uname6[]=new String[otherregistrations.size()];//登簿人
        Integer preid[]=new Integer[otherregistrations.size()]; //预告注销业务宗号

        for (int i=0;i<otherregistrations.size();i++ ) {
            Otherregistration o = otherregistrations.get(i);
            sid1[i]=o.getServiceid();//业务宗号
            type1[i]=registrationtypeDao.selectByPrimaryKey(o.getRegistrationtypeid()).getRegistrationtype();//登记种类
            obl[i] =clientDao.selectByPrimaryKey(o.getObligee()).getClientname();
            no1[i]= clientDao.selectByPrimaryKey(o.getObligee()).getIdcard();
            obl2[i]=clientDao.selectByPrimaryKey(o.getObligor()).getClientname();
            no2[i]=clientDao.selectByPrimaryKey(o.getObligor()).getIdcard();
            preno[i]=o.getPrevregisternumber();
            time1[i]=o.getRegistertime();
            uname6[i]=userinfoDao.selectByPrimaryKey(o.getUid()).getUname();
            preid[i]= o.getId();
        }
        rbl.setPreid(preid);
        rbl.setUname6(uname6);
        rbl.setTime1(time1);
        rbl.setPreno(preno);
        rbl.setNo2(no2);
        rbl.setObl2(obl2);
        System.out.println("aaaaaaaaaaaaaaaaaa:"+Arrays.toString(obl));
        rbl.setNo1(no1);
        rbl.setObl(obl);
        rbl.setType1(type1);
        rbl.setSid1(sid1);

        //查封登记
        //门牌号
        String roomnumber = roomDao.selectByPrimaryKey(rb.getRoomid()).getRoomnumber();

        CloseregistrationExample example7 = new CloseregistrationExample();
        CloseregistrationExample.Criteria criteria7 = example7.createCriteria();
        criteria7.andDescriptEqualTo(roomnumber);
        List<Closeregistration> closeregistrationList = closeregistrationDao.selectByExample(example7);

        Integer sid[]=new Integer[closeregistrationList.size()];//业务宗号
        String closeoffices[]=new String[closeregistrationList.size()]; //查封机关
        String closefiles[]=new String[closeregistrationList.size()]; //查封文件
        String closefilesnumber[]=new String[closeregistrationList.size()];//查封文号
        Date closetimes[]=new Date[closeregistrationList.size()];//查封时间
        Date closeDate[]=new Date[closeregistrationList.size()];//查封期限
        Date registertime3[]=new Date[closeregistrationList.size()];//登记时间
        String uname3[]=new String[closeregistrationList.size()];//终审人/登簿人
        Integer closeservieids[]=new Integer[closeregistrationList.size()];//查封注销业务宗号
        String openfile[]=new String[closeregistrationList.size()];//解除查封文件
        Date opentime[]=new Date[closeregistrationList.size()];//解除查封时间
        Date openRegistertime[]=new Date[closeregistrationList.size()];//解除登记时间
        String openfilesnumber[]=new String[closeregistrationList.size()];//解除查封文号

        for (int i=0;i<closeregistrationList.size();i++){
            sid[i]=closeregistrationList.get(i).getServiceid();//业务宗号
            Integer closeofficeid = closeregistrationList.get(i).getCloseofficeid();
            closeoffices[i]=closeofficeDao.selectByPrimaryKey(closeofficeid).getCloseoffice();//查封机关
            closefiles[i]=closeregistrationList.get(i).getClosefile();//查封文件
            closefilesnumber[i]=closeregistrationList.get(i).getClosefilenumber();//查封文号
            closetimes[i]=closeregistrationList.get(i).getClosetime();
            closeDate[i]=closeregistrationList.get(i).getClosedate();
            registertime3[i]=closeregistrationList.get(i).getRegistertime();
            uname3[i]=userinfoDao.selectByPrimaryKey(closeregistrationList.get(i).getUid()).getUname();
            closeservieids[i]=closeregistrationList.get(i).getCloseserviceid();
            openfile[i]="已解除查封";
            opentime[i]=closeregistrationList.get(i).getOpentime();
            openRegistertime[i]=closeregistrationList.get(i).getOpenregistertime();
            openfilesnumber[i]=closeregistrationList.get(i).getClosefilenumber();
        }
        rbl.setOpenfilesnumber(openfilesnumber);
        rbl.setOpentime(opentime);
        rbl.setOpenRegistertime(openRegistertime);

        rbl.setOpenfile(openfile);
        rbl.setCloseservieids(closeservieids);
        rbl.setUname3(uname3);
        rbl.setClosetimes(closetimes);
        rbl.setCloseDate(closeDate);
        rbl.setRegistertime3(registertime3);
        rbl.setClosefilesnumber(closefilesnumber);
        rbl.setClosefiles(closefiles);
        rbl.setSid(sid);
        rbl.setCloseoffices(closeoffices);




        //他项权（现房抵押）
        List<Existmortgage> list1=new ArrayList<>();
        ExistmortgageExample example4= new ExistmortgageExample();
        ExistmortgageExample.Criteria criteria4 = example4.createCriteria();
        criteria4.andRoomidEqualTo(roomids[0]);
        List<Existmortgage> existmortgageList = existmortgageDao.selectByExample(example4);
        String mortgages[]=new String[existmortgageList.size()];//一般抵押，最高抵押
        String md[]=new String[existmortgageList.size()];// //抵押人，债务人
        String mortgagees []=new String[existmortgageList.size()];//抵押权人

//        String [] scopes=new String[existmortgageList.size()];//担保范围
//        Date [] retumtimes=new Date[existmortgageList.size()]; //债务履行期限
        String maxclaimes[]=new String[existmortgageList.size()];//最高债权数额
        String scopes[]=new String[existmortgageList.size()];//担保范围
        Date returntimes[]=new Date[existmortgageList.size()];//债务履行期限
        Integer [] dyzhenghaoes=new Integer[existmortgageList.size()];//他项权证号
        Date registertimes1[]=new Date[existmortgageList.size()];//他项权登记时间组
        Integer serviceides1[]=new Integer[existmortgageList.size()];//业务宗号组
        Integer  cancelserviceides []=new Integer[existmortgageList.size()];//抵押注销业务宗号
        String [] uname1=new String[existmortgageList.size()];//登簿人

        for (int i=0;i<existmortgageList.size();i++ ) {
            Existmortgage e = existmortgageList.get(i);
            BigDecimal generalmortgage = e.getGeneralmortgage();
            BigDecimal maxmortgage =e.getMaxmortgage();
           //一般抵押，最高抵押
            mortgages[i]=generalmortgage+"/"+maxmortgage;

            //抵押人，债务人
            String clientname2 = clientDao.selectByPrimaryKey(e.getMortgager()).getClientname();//抵押人
            String clientname1 = clientDao.selectByPrimaryKey(e.getDebtor()).getClientname();//债务人
             md[i]=clientname2+"/"+clientname1;
             //最高债权数额
            maxclaimes[i]=e.getMaxclaim()+" ";
            //担保范围
            scopes[i]=e.getScope();
            //债务履行期限
            returntimes[i]=e.getReturntime();
            //他项权证号
            dyzhenghaoes[i]=e.getEmid();
            //他项权登记时间组
            registertimes1[i]=e.getRegistertime();
            //业务宗号组
            serviceides1[i]=e.getServiceid();
            //抵押注销业务宗号
            cancelserviceides[i]=e.getCancelserviceid();
            //抵押权人
            mortgagees[i]=clientDao.selectByPrimaryKey(e.getMortgagee()).getClientname();
             //登簿人
            uname1[i]=userinfoDao.selectByPrimaryKey(e.getUid()).getUname();

        }
        rbl.setUname1(uname1);
        rbl.setMortgagees(mortgagees);
        rbl.setCancelserviceides(cancelserviceides);
        rbl.setServiceides1(serviceides1);
        rbl.setRegistertimes1(registertimes1);
        rbl.setDyzhenghaoes(dyzhenghaoes);
        rbl.setReturntimes(returntimes);
        rbl.setScopes(scopes);
        rbl.setMaxclaimes(maxclaimes);
        rbl.setMd(md);
        rbl.setMortgages(mortgages);


        rbl.setRegistertimes(registertimes);
         rbl.setGnames(gnames);
        System.out.println("业务id组:"+Arrays.toString(serviceids));


        //(他项权)在建抵押

        BeinmortgageExample example5= new BeinmortgageExample();
        BeinmortgageExample.Criteria criteria5 = example5.createCriteria();
        criteria5.andRoomidEqualTo(roomids[0]);
        List<Beinmortgage> beinmortgageList = beinmortgageDao.selectByExample(example5);

        Integer [] serviceides2 =new Integer[beinmortgageList.size()];//业务宗号组
        String [] mortgages2=new String[beinmortgageList.size()];//一般抵押、最高抵押
         String [] mortagee=new String[beinmortgageList.size()]; //抵押权人
        String[] location1=new String[beinmortgageList.size()];//在建工程坐落
        String [] maxclaim1=new String[beinmortgageList.size()];//最高债权数额
        String [] scopes1=new String[beinmortgageList.size()];//担保范围
        Date [] returntime1=new Date[beinmortgageList.size()];//债务履行期限
        Date [] registertime2=new Date[beinmortgageList.size()];//登记时间
        String [] uname2=new String[beinmortgageList.size()];//登簿人
        Integer [] serviceids2=new Integer[beinmortgageList.size()];//业务宗号
        Integer[] cancelserviceids2=new Integer[beinmortgageList.size()];//抵押注销业务宗号

        for (int i=0;i<beinmortgageList.size();i++ ) {
            Beinmortgage b = beinmortgageList.get(i);
            serviceides2[i]=b.getServiceid();//业务宗号组
            mortgages2[i]= b.getGeneralmortgage()+"/"+b.getMaxmortgage();//一般抵押、最高抵押
            mortagee[i]=clientDao.selectByPrimaryKey(b.getMortgagee() ).getClientname();//抵押权人
            location1[i]=b.getLocation();//在建工程坐落
            maxclaim1[i]=b.getMaxclaim()+"";//最高债权数额
            scopes1[i]=b.getScope();//担保范围
            returntime1[i]=b.getReturntime(); //债务履行期限
            registertime2[i]=b.getRegistertime();//登记时间
            System.out.println("1:"+b.getUid());
            System.out.println("2:"+userinfoDao.selectByPrimaryKey(b.getUid()));
            System.out.println("3:"+userinfoDao.selectByPrimaryKey(b.getUid()).getUname());

            uname2[i]=userinfoDao.selectByPrimaryKey(b.getUid()).getUname();
            serviceids2[i]=b.getServiceid();
            cancelserviceids2[i]=b.getCancelserviceid();
        }
        rbl.setCancelserviceids2(cancelserviceids2);
        rbl.setServiceids2(serviceids2);
        rbl.setUname2(uname2);

        rbl.setRegistertime2(registertime2);//登记时间
        rbl.setReturntime1(returntime1);//债务履行期限
        rbl.setScopes1(scopes1);//担保范围
        rbl.setMaxclaim1(maxclaim1);  //最高债权数额
        rbl.setLocation1(location1);//在建工程坐落
        rbl.setMortagee(mortagee);//抵押权人
        rbl.setServiceides2(serviceides2);//业务宗号组
        rbl.setMortgages2(mortgages2);//一般抵押、最高抵押








        //根据房屋id组查到所有权组的业务宗号组
         String [] servicenumbers=new String[roomids.length];
//        String [] rnames1=new String[roomids.length];//房屋性质组
        Integer [] buildingids=new Integer[roomids.length];//楼栋id组
        Integer [] housesids=new Integer[roomids.length];//楼盘id组
        Integer [] rnameids=new Integer[roomids.length];//楼盘id组
//        Data [] registertimes=  new Date[roomids.length];//登记时间组

        for (int i=0;i<roomids.length;i++){
            OwnershipExample example2 = new OwnershipExample();
            OwnershipExample.Criteria criteria1 = example2.createCriteria();
            criteria1.andRoomidEqualTo(roomids[i]);
            //业务宗号组
            servicenumbers[i]=ownershipDao.selectByExample(example2).get(0).getServicenumber();
            //所有权证号组
            osids[i]=ownershipDao.selectByExample(example2).get(0).getOsid();
            //用户名称组
            unames[i] =userinfoDao.selectByPrimaryKey(ownershipDao.selectByExample(example2).get(0).getUid()).getUname();

            //获取楼栋组
            buildingids[i] = roomDao.selectByPrimaryKey(roomids[i]).getBuildingid();//楼栋组
            housesids[i]=buildingDao.selectByPrimaryKey(buildingids[i]).getHid();//楼盘id组
            rnameids[i] = houseDao.selectByPrimaryKey(housesids[i]).getRid();//房屋性质id组
            rnames[i]=roomtypeDao.selectByPrimaryKey(rnameids[i]).getRname();//房屋性质组


        }
        rbl.setUnames(unames);
        rbl.setOsids(osids);
     rbl.setServicenumbers(servicenumbers);
        rbl.setRnames(rnames);


        for(int i=0;i<serviceids.length;i++){
            System.out.println("业务id："+serviceids[i]);



            //根据业务id组查到共有人表对象组
            ServiceshareExample example2 = new ServiceshareExample();
            ServiceshareExample.Criteria criteria2 = example2.createCriteria();
            criteria2.andServiceidEqualTo( serviceids[i]);

            Serviceshare serviceshare = serviceshareDao.selectByExample(example2).get(0);

            System.out.println("客户id："+serviceshare.getClientid());
            Client client = clientDao.selectByPrimaryKey(serviceshare.getClientid());//客户对象
            String clientname =client!=null?client.getClientname():"";
            Integer share = serviceshare.getShare();//份额
            idcards[i]=client.getIdcard();//身份证组
            addresses[i]=client.getAddress();//户籍地址组

            clientnames[i]=clientname;
            if(serviceshare.getSharetypeid()==3){
                str+=clientname;
            }else{
                str+=clientname + "(" + share + ")" + " ";
            }
            commones[i]=str;

        }
        System.out.println("共有人表对象组:"+str);

        rbl.setCommones(commones);
        rbl.setAddresses(addresses);
        rbl.setIdcards(idcards);
        rbl.setClientnames(clientnames);
        rbl.setObligeeAndShare(str);
        //4、丘号
        rbl.setQiuhao(rb.getClientid());//自定义值
        System.out.println("丘号:"+rb.getClientid());
        //5、登记时间
        //根据网签对象查到网签时间
        NetsignExample example6 = new NetsignExample();
        NetsignExample.Criteria criteria1 = example6.createCriteria();
        criteria1.andRoomidEqualTo(rb.getRoomid());
        Netsign netsign = netsignDao.selectByExample(example6).get(0);
        System.out.println("登记时间:"+netsign.getNettime());
        rbl.setRegistertime(netsign.getNettime());
        //6、登簿人
        String uname = userinfoDao.selectByPrimaryKey(rb.getUid()).getUname();
        System.out.println("登簿人:"+uname);
        rbl.setUname(uname);
        //7、房屋id
        System.out.println("房屋id"+rb.getRoomid());
        rbl.setRoomid(rb.getRoomid());









        list.add(rbl);
       return  AjaxResponse.success(list);

    }
//
    @Override
    public AjaxResponse delRegisterBook(int registerBookNo) {
        System.out.println("删除的编号："+registerBookNo);
        RegisterbookExample example = new RegisterbookExample();
        RegisterbookExample.Criteria criteria = example.createCriteria();
        criteria.andRegisterbooknoEqualTo(registerBookNo);
        Registerbook registerbook = registerbookDao.selectByExample(example).get(0);

        registerbook.setDelstatus(0);
        int i = registerbookDao.updateByPrimaryKeySelective(registerbook);

        return  AjaxResponse.success(i);
    }
}
